package com.tianji.promotion.controller;


import com.tianji.promotion.service.IUserCouponService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;

/**
 * <p>
 * 用户领取优惠券的记录，是真正使用的优惠券信息 前端控制器
 * </p>
 *
 * @author ltd
 * @since 2024-07-04
 */
@RestController
@RequestMapping("/user-coupons")
@RequiredArgsConstructor
@Api(tags = "用户的优惠卷相关接口")
public class UserCouponController {
    private final IUserCouponService userCouponService;

    @PostMapping("/{id}/receive")
    @ApiOperation("领取发放中的优惠卷")
    public void collectTheVoucher(@PathVariable @Valid Long id){

        userCouponService.collectTheVoucher(id);
    }

    @PostMapping("/{code}/exchange")
    @ApiOperation("兑换码兑换优惠卷")
    public void exchangeCoupon(@PathVariable @Valid String code){
      userCouponService.exchangeCoupon(code);


    }
}
